Repository navigation
EMRY-006: EventBus pub/sub fan-out (bounded, drop-and-count) - #54
Merged
Merged
Conversation
Multi-subscriber fan-out over crossbeam unbounded channels: subscribe() returns an independent Receiver; publish(&Event) clones to each live subscriber, prunes dropped ones, and never blocks on a slow observer. Send+Sync for sharing behind Arc. Tests: 2 subscribers x 100 events in order, no-sub no-op, dead-subscriber pruning, cross-thread delivery.
Switch per-subscriber channels from unbounded to bounded(DEFAULT_SUBSCRIBER_ CAPACITY=16_384) with try_send: a stalled subscriber has events dropped and counted (dropped()) rather than growing memory without limit, matching the ring buffer's backpressure policy. Disconnected receivers still pruned.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes EMRY-006 (#7). Branched off
main. Completes M0.What
crates/emry-core/src/bus.rs—EventBusmulti-subscriber fan-out overcrossbeam_channel.subscribe()returns an independentReceiver;publish(&Event)clones to each live subscriber and never blocks.Backpressure (review-driven)
Per-subscriber channels are bounded (
DEFAULT_SUBSCRIBER_CAPACITY= 16 384) withtry_send: a stalled observer (e.g. wedged TUI render) has events dropped and counted (dropped()) instead of growing memory without limit — mirroring the ring buffer policy and the project's 'never harm the run' ethos. Disconnected receivers are pruned.Verification
./scripts/pre-commit-rust.shgreen: fmt, clippy-D warnings, tests, bus.rs 98% linesReview notes
try_send; engine drains on one thread) and documented the trade-off rather than adding a per-publish sender-list clone.